<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增用印信息')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-info-add" th:object="${vo}">
            <input type="hidden" th:field="*{chopId}"/>
            <input type="hidden" th:field="*{caseNo}"/>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">用印名称：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" th:field="*{chopName}" required>
                </div>
            </div>
            
            <div class="form-group">
	            <div id="element_ct">
            		<label class="col-sm-3 control-label is-required">印章类型：</label>
                       <div class="col-sm-2">
                         <select class="type form-control m-b" th:field="*{chopGroup}" required data-first-title="请选择">
		                  	<option value="">请选择</option>
		                  	<option th:value="*{chopGroup}" th:selected="1"></option>
		                </select>
	                </div>
		            <label class="col-sm-3 control-label is-required">申请类型：</label>
		            <div class="col-sm-2">
		                <select class="router form-control m-b" th:field="*{chopTypeId}" required data-first-title="请选择">
		                  <option value="">请选择</option>
		                  <option th:value="*{chopTypeId}" th:selected="1"></option>
		                </select>
		           </div>
	            </div>
            </div>
            
            <div class="form-group">
	            <div>
            		<label class="col-sm-3 control-label is-required">何种印章：</label>
	                <div class="col-sm-2">
			 			<select class="form-control m-b" th:field="*{sealTypeId}" required>
			            <option value="">请选择</option>
				 		<option th:each="u : ${sealTypes}" th:text="${u.name}" th:value="${u.id}" th:field="*{sealTypeId}"></option>
						</select>
	               </div>
		           <label class="col-sm-3 control-label is-required">文件份数：</label>
		           <div class="col-sm-2">
		              <input type="text" class="router form-control m-b" th:field="*{copies}" required>
		           </div>
	            </div>
            </div>
            
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">用印状态：</label>
                    <div id="element_ct" class="row">
                        <div class="col-sm-2">
			             	<select class="form-control m-b" th:field="*{status}" disabled="true" required>
			                    <option value="">请选择</option>
				      			<option th:each="u : ${chopStatus}" th:text="${u.name}" th:value="${u.id}" th:field="*{status}"></option>
				   			</select>
		                </div>
                	</div>
            </div>

            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remark" class="form-control" type="text" th:field="*{remark}">
                </div>
            </div>
        </form>
    </div>
    [[${vo.chopId}]]/[[${vo.status}]]
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
        	<button type="button" class="btn btn-sm btn-primary" onclick="saveHandler()"><i class="fa fa-save"></i>保 存</button>&nbsp;
        	<button type="button" class="btn btn-sm btn-default"  onclick="javascript:void(0)" disabled="true"><i class="fa fa-check"></i>申 请</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: jquery-cxselect-js" />
           
    <script th:inline="javascript">
        var prefix = ctx + "office/chopinfo/enroll"
        $("#form-info-add").validate({
            focusCleanup: true
        });

        function saveHandler() {
	    	$.ajax({
	            url: prefix + "/add",
	            data: $('#form-info-add').serialize(),
	            type: "post",
	            success: function(result) {
	            	if (result.code == web_status.SUCCESS) {
	            		layer.msg("保存成功,正在刷新数据请稍候……", {
		            	    icon: 1,
		            	    time: 500,
		            	    shade: [0.1, '#8F8F8F']
		            	},function() {
		            		window.location.href = prefix + "/edit/" + result.id;
		            		/* $.modal.confirm("是否要提交申请吗?", function() {
		            			$.modal.openTab("修改用章信息", prefix + "/edit/" + result.id);
		            			closeItem();
		            		}); */
		            	});
	            	} else {
	            		alert(result.msg);
	            	}
	            }
	        })
        }
   </script>
   
	<script th:inline="javascript">
		// 直接返回获取
		var ctData = [[${ctData}]];
		$('#element_ct').cxSelect({
		  selects: ['type', 'router'],
		  jsonValue: 'v',
		  data: ctData
		});
	</script>
    
</body>
</html>